package cn.kgc.mushroomwebui.controller;

import cn.kgc.mushroomcommon.api.ManagerRemoteService;
import cn.kgc.mushroomcommon.pojo.ResultEntity;
import cn.kgc.mushroomcommon.pojo.Shoppingcar;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/shoppingcar/manager")
public class ShoppingCarController {

    @Resource
    ManagerRemoteService managerRemoteService;

    @RequestMapping("/to/cart")
    public String toCart(){
        return "cart";
    }

    @ResponseBody
    @RequestMapping("/query/shoppingcar/list")
    public List<Shoppingcar> selectShoppingCarList(){
        return managerRemoteService.selectShoppingCarList();
    }


    @ResponseBody
    @RequestMapping("/batch/remove")
    public Integer batchRemove(@RequestBody List<Integer> shoppingCarIdList) {
        return managerRemoteService.batchRemove(shoppingCarIdList);
    }

    @ResponseBody
    @RequestMapping("/query/shoppingcar/list/by/id/list")
    public List<Shoppingcar> getShoppingCarListByIdList(@RequestBody List<Integer> shoppingCarIdList){
        return managerRemoteService.getShoppingCarListByIdList(shoppingCarIdList);
    }

    @ResponseBody
    @RequestMapping("/addShopCar")
    public ResultEntity<String> addShopCar(@RequestBody Shoppingcar shoppingcar) {
        return managerRemoteService.addShopCar(shoppingcar);
    }
}
